<admintpl file="header" />
</head>
<body>
<div class="wrap">
    <ul class="nav nav-tabs">
        <!--<li><a href="{:U('Admin/News/index')}">新闻列表</a></li>-->
        <!--<li><a href="{:U('Admin/News/pindex')}">采集新闻</a></li>-->
        <!--<li class="active"><a href="#">快捷发布</a></li>-->
    </ul>
    <form method="post" enctype="multipart/form-data" class="form-horizontal js-ajax-form" id="pub_form" action="{:U('Admin/NewsVideo/add_videoNews')}">
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">视频标题：</label>
            <div class="span3">
                <input type="text" name="title"  style="width: 556px;" value="{$news_info.title}">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">副标：</label>
            <div class="span3">
                <input type="text" name="subTitle"  style="width: 556px;" value="{$news_info.subtitle}">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">关键字：</label>
            <div class="span3">
                <input type="text" name="keyword"  style="width: 556px;" value="{$news_info.keywords}">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">视频来源：</label>
            <div class="span3">
                <input type="text" name="source"  style="width: 556px;" value="{$news_info.source_name}">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">权重：</label>
            <div class="span3">
                <input type="text" name="weight"  style="width: 556px;" value="{$news_info.weight}">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">标签：</label>
            <div class="span3">
                <input type="text" name="tags"  style="width: 556px;" value="{$news_info.tags}">
            </div>
        </div>
        <div class="control-group">
            <label class="span2 control-label" style="width: 90px;">新闻摘要：</label>
            <div class="span7">
                <textarea style="width: 556px; height: 60px;" name="abstract">{$news_info.abstract}</textarea>
            </div>
        </div>
      	<?php if($type != '2'){?>
		<div class="control-group">
			<label class="span1 control-label" style="width: 90px;">是否置顶：</label>
			<div class="span3">
				<label class="radio inline" for="lightup_true"> <input type="radio" id="top_status" <if condition="$news_info.top_status eq 1"> checked </if> class="radio" name="top_status" value="1" />是</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				<label class="radio inline" for="lightup_false"> <input type="radio" id="top_status" <if condition="$news_info.top_status eq 0"> checked </if> class="radio" name="top_status" value="0" />否</label>
			</div>
		</div>
		<?php }?>
        <?php if($type == '2'){?>
				<div class="control-group">
					<label class="span1 control-label" style="width: 90px;">专题分栏：</label>
					<div class="span3">
						<select class="select_2" name="special_type" id="special_type" >
							<foreach name="special_column_type_list" item="vo">
								<option value="{$vo.type_id}" <?php if(isset($type_id)){ if($vo['type_id'] == $type_id) echo "selected";}?> >{$vo.name}</option>
							</foreach>
						</select>
					</div>
				</div>
				<?php }else{?>
				<div class="control-group">
	            <label class="span1 control-label" style="width: 90px;">栏目类型：</label>
		            <div class="span3">
		                <select class="select_2" name="column_type" id="column_type" >
		                    <foreach name="type_list" item="vo">
		                        <option value="{$vo.type_id}" <?php if($vo['type_id']==$news_info['type_id']) {echo "selected";}?>>
		                        {$vo.name}</option>
		                    </foreach>
		                </select>
		            </div>
				</div>
		<?php } ?>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">封面图片：</label>
            <div class="span4 wrapper">
                <div id="uploader-image">
                    <div id="fileList" class="uploader-list">
                        <div id="imageDiv" class="file-item thumbnail" style="width:150px;height: 150px;">
                            <?php
                                if(!empty($news_info['cover_image'])){
                            ?>
                                <img id="imagePreview" src="{$news_info.cover_image}" style="width:150px;height: 140px;">
                                <?php
                                }else{
                                ?>
                                <img id="imagePreview" src="__PUBLIC__/images/furley_bg.png" style="width:150px;height: 140px;">
                                <?php
                                }
                                ?>
                            <div id="picker" class="info">选择图片&nbsp;&nbsp;&nbsp;&nbsp;</div>
                            <input style="display:none;" type="file" id="imageFile" name="imageFile" >
                        </div>
                    </div>
                </div>
            </div><div style="color:red;float:left;margin-top:140px">*视频封面缩略  尺寸：270*186  格式：JPG/PNG</div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">是否VR：</label>
            <div class="span3">
                <select class="select_2" name="is_vr" id="is_vr" >
                    <option value="1" <if condition="$news_info.category eq 2"> selected </if>>是</option>
                    <option value="0" <if condition="$news_info.category eq 1 or $news_info.category eq '' "> selected </if>>否</option>
                </select>
            </div>
        </div>
        <div class="control-group">

            <label class="span2 control-label" style="width: 90px;">选择视频：</label>
            <div class="span7">
                <a class="btn btn-primary"  onclick="open_upload()">上传视频</a>
                <input type="hidden" name="fileName" id="fileName" value="">
                <input type="hidden" name="fileSize" id="fileSize" value="">
                <input type="hidden" name="fileDir" id="fileDir" value="<?php echo time().rand();?>">
                <span id="upload_file_name_show"></span>
            </div>
        </div>
        
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">腾讯云文件名</label>
            <div class="span3">
                <input type="text" name="qcloud_file_name"  style="width: 556px;" value="{$news_info.file_name}">
            </div>
        </div>
        
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">腾讯云file_id</label>
            <div class="span3">
                <input type="text" name="file_id"  style="width: 556px;" value="{$news_info.file_id}">
            </div>
        </div>
        
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">发布渠道：</label>
            <div class="span3">
                <label class="radio inline" for="lightup_true"> <input type="checkbox" <if condition="$news_info.app_pub eq 1"> checked </if> id="pub" class="radio" name="pub[]" value="1" />APP</label> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <label class="radio inline" for="lightup_false"> <input type="checkbox" id="pub" <if condition="$news_info.web_pub eq 1"> checked </if>  class="radio" name="pub[]" value="2" />门户</label>
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">内部链接：</label>
            <div class="span3" style="width:556px">
                <input type="text" name="reference"  style="width: 556px;" value="<?php if($news_info['reference_id'] && $news_info['reference_type']) echo "id=".$news_info['reference_id']."&type=".$news_info['reference_type'];?>">
            </div>
            <?php if($news_info['reference_id'] && $news_info['reference_type']){ ?>
				<div style="float: left; margin-left: 50px;"><a href="<?php echo U('NewsManage/publish', array('news_id'=>$news_info['reference_id']));?>">维护新闻</a></div>
			<?php } ?>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">引入路径：</label>
			<div class="span3">
				<input type="text" name="outer_url"  style="width: 556px;" value="{$news_info.outer_url}">
				<label  for="lightup_false"> <input type="checkbox" id="outer_url_pub" <if condition="$news_info.outer_url_ishot eq 1"> checked </if>  class="radio" name="outer_url_pub" value="1" />设为新闻链接</label>
			</div>
        </div>
        <?php
        if(!empty($news_info['relation'])){
            foreach($news_info['relation'] as $key=>$val){
        ?>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;"><?php if($key == '0') echo '关联新闻：';?></label>
            <div class="span3" style="float: left;">
                <input type="text" name="news_recommend[]"  style="width: 556px;" value="<?php echo "id=".$val['recommend_id']."&type=".$val['type'].'&weight='.$val['weight'];?>">
            </div>
        </div>
        <?php
            }
        }else{
        ?>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;">推荐新闻：</label>
            <div class="span3" style="float: left;">
                <input type="text" name="news_recommend[]"  style="width: 556px;" value="">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;"></label>
            <div class="span3" style="float: left;">
                <input type="text" name="news_recommend[]"  style="width: 556px;" value="">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;"></label>
            <div class="span3" style="float: left;">
                <input type="text" name="news_recommend[]"  style="width: 556px;" value="">
            </div>
        </div>
        <div class="control-group">
            <label class="span1 control-label" style="width: 90px;"></label>
            <div class="span3" style="float: left;">
                <input type="text" name="news_recommend[]"  style="width: 556px;" value="">
            </div>
        </div>
        <?php
        }
        ?>

        <input type="hidden" name="{$id_type}"  value="{$id_val}" style="width: 556px;">
        <input type="hidden" name="special_id"  value="{$special_id}" style="width: 556px;">
        <input type="hidden" name="news_id"  value="{$news_id}" style="width: 556px;">
        <div class="form-actions" style="padding-left:260px;">
            <button type="button" id="quick_publish" class="btn js-ajax-form">保存</button>
            &nbsp;&nbsp;
            <if condition="$type eq 2">
            	<a class="btn" href="{:U('Admin/Special/index',array('special_id'=>$special_id,$id_type=>$id_val))}">{:L('BACK')}</a>
            <else/>
            	<a class="btn" href="{:U('Admin/News/index?'.$id_type.'='.$id_val)}">{:L('BACK')}</a>
            </if>
            
        </div>
    </form>
</div>
<script src="__PUBLIC__/js/common.js"></script>
<script src="__PUBLIC__/js/publish.js"></script>
<script src="__PUBLIC__/js/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.DIMAUB;
</script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" >
function setUpload(fileName, fileSize){
    $("#fileName").val(fileName);
    $("#fileSize").val(fileSize);
    $("#upload_file_name_show").html(fileName);
}  

function getFileDir(){
    return $("#fileDir").val();
}  
    
function open_upload(){
	  layer.open({
	    type: 2,
	    //skin: 'layui-layer-lan',
	    title: '上传视频',
	    fix: false,
	    shadeClose: true,
	    maxmin: true,
	    area: ['1000px', '500px'],
	    content: "<?php echo U('Admin/NewsVideo/open_upload')?>",
	    end: function(){
	    }
	  });
}

    $(document).ready(function () {
        $('#channelId').change(function () {
            $.get('{:U("Admin/News/ajax_get_subject")}' + '&cateId=' + $('#channelId').val(), function (data) {
                var html = '<option value="0">--无--</option>';
                if(data['state']=="success"){
                    html = '<option value="-1">全部</option>';
                    for (var a in data.tagList) {
                        html += '<option value="' + data.tagList[a].tagTitle + '">' + data.tagList[a].tagTitle + '</option>';
                    }
                }
                $('#subjectId').html(html);
            });
        });
    });
    function html5Reader(file, previewId){
        var file = file.files[0];
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function(e){
            $('#'+previewId).attr('src', this.result);
        }
    }
    function image_change(fileId, previewId) {
        var pic = document.getElementById(previewId),
                file = document.getElementById(fileId);

        var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

        // gif在IE浏览器暂时无法显示
        if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
            alert("图片的格式必须为png或者jpg或者jpeg格式！");
            return;
        }
        var isIE = navigator.userAgent.match(/MSIE/)!= null,
                isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

        if(isIE) {
            file.select();
            var realLocalPath = document.selection.createRange().text;

            // IE6浏览器设置img的src为本地路径可以直接显示图片
            if (isIE6) {
                pic.src = realLocalPath;
            }else {
                // 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
                pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
                // 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
                pic.src = '';
            }
        }else {
            html5Reader(file, previewId);
        }
    }

    $("#picker").click(function(){
        $("#imageFile").click();
    });

    $("#imageFile").change(function(){
        image_change('imageFile', 'imagePreview');
    });
</script>
</body>
</html>